<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>添加权限 </title>
    <meta name="robots" content="noindex, nofollow"/>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="__CSS__/general.css" rel="stylesheet" type="text/css" />
    <link href="__CSS__/main.css" rel="stylesheet" type="text/css" />
    <link href="__ZTREE__/zTreeStyle.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>
    <span id="search_id" class="action-span1"> - 添加权限 </span>
</h1>
<div style="clear:both"></div>
<div class="main-div">
    <form action="{:U()}" method="post" name="theForm" enctype="multipart/form-data">
        <table width="100%" id="general-table">
            <tr>
                <td class="label">权限名称:</td>
                <td>
                    <input type='text' name='name' value='{$row.name}' size='27' />
                </td>
            </tr>
            <tr>
                <td class="label">操作路径:</td>
                <td>
                    <input type='text' name='path' value='{$row.path}'  />
                </td>
            </tr>
            <tr>
                <td class="label">上级权限:</td>
                <td>
                    <input type="hidden" name="parent_id" id="parent_id" value="{$row.parent_id}"/>
                    <ul id="parent_nodes" class="ztree"></ul>
                </td>
            </tr>
            <tr>
                <td class="label">描述:</td>
                <td>
                    <textarea name="intro" style='resize: none;' cols="60" rows="6">{$row.intro}</textarea>
                </td>
            </tr>
        </table>
        <div class="button-div">
            <input type="hidden" name="id" value='{$row.id}'/>
            <input type="submit" value=" 确定 " />
            <input type="reset" value=" 重置 " />
        </div>
    </form>
</div>
<js href="__JS__/jquery.min.js"/>
<js href="__ZTREE__/jquery.ztree.core.min.js"/>

<script type="text/javascript">
    $(function() {
        $('#parent_id').val([{$row.parent_id}]);
    });


    var setting = {
        data: {
            simpleData: {
                enable: true,
                pIdKey:'parent_id',
            }
        },
        callback:{
            onClick:function(event,ele_id,node){
                $('#parent_id').val(node.id);
            },
        },
    };

    var zNodes = {$permissions};

    $(document).ready(function() {
        var ztree_obj = $.fn.zTree.init($("#parent_nodes"), setting, zNodes);
        ztree_obj.expandAll(true);
        <present name="row">
        //回显数据，选中父级节点
        //找到节点
        var parent_node = ztree_obj.getNodeByParam('id',{$row.parent_id});
        ztree_obj.selectNode(parent_node)
        </present>
    });
</script>
</body>
</html>